package com.yubest;

/**
 * @Author hweiyu
 * @Description
 * @Date 2022/1/25 11:00
 */
public class P1688 {
}

class Solution1688 {

    public int numberOfMatches(int n) {
        int sum = 0;
        while (n > 1) {
            //偶数
            if ((n & 1) == 0) {
                sum += n / 2;
                n /= 2;
            } else {
                sum += (n - 1) / 2;
                n = (n - 1) / 2 + 1;
            }
        }
        return sum;
    }
}
